/*
 * jxDao Project (2014)
 * 
 * by Denilson Edinaldo Pinto
 * 
 * LGPL
 * Copyright (C) 2014
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxDao.dao.db;

import java.io.Serializable;

import org.jxUtils.check.ParameterCheck;

/**
 * @author Denilson Edinaldo Pinto
 * @porject jxDao
 * @package org.jxDao.dao.db
 * @date 11/04/2014 - 12:46:26
 */
public enum Driver implements Serializable {
	
	DERBY("org.apache.derby.jdbc.EmbeddedDriver"),
	FIREBIRD("org.firebirdsql.jdbc.FBDriver"),
	MYSQL("com.mysql.jdbc.Driver"),
	ORACLE("oracle.jdbc.OracleDriver"),
	ODBC("sun.jdbc.odbc.JdbcOdbcDriver"),
	POSTGRESQL("org.postgresql.Driver"),
	SQLITE("org.sqlite.JDBC"),
	SQLSERVER("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	
	private String driverName;
	
	/**
	 * @param driverName
	 */
	Driver(final String driverName) {
	
		this.driverName = driverName;
	}
	
	/**
	 * @return the driverName
	 */
	public String getName() {
	
		return driverName;
	}
	
	/**
	 * @param driver
	 * @return the default port to {@link Driver}
	 */
	public static String getDefaultPort(final Driver driver) {
	
		ParameterCheck.isNull(driver, "driver");
		
		return driver.equals(DERBY) ? "" : driver.equals(FIREBIRD) ? "3050" : driver.equals(MYSQL) ? "3306" : driver.equals(ORACLE) ? "1521" : driver.equals(ODBC) ? "" : driver.equals(POSTGRESQL) ? "5432" : driver.equals(SQLITE) ? "" : driver.equals(SQLSERVER) ? "1433" : "";
	}
}
